home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
157_01
/
qed1
< prev
next >
Wrap
Text File
|
1987-10-10
|
12KB
|
561 lines
/* VERSION 0004 (DATE: 03/03/87) (TIME: 11:07) */
/*
e (qed) screen editor
(C) G. Nigel Gilbert, MICROLOGY, 1981
August-December 1981
Modified: Aug-Dec 1984: BDS-C 'e'(vers 4.6a) to 'qe' (J.W.Haefner)
March 1985: BDS-C 'qe' to DeSmet-C 'qed' (J.W.Haefner)
FILE: qe1
FUNCTIONS: dirmsk,
printdirectory, envir, files, putonoff, getnumb, getlow
PURPOSE: environment; change files.
*/
#include "qed.h"
#define EXTENT 12
#define RECORDS 15
#define EXTSIZ 128
#if CPM /*NOTE: <<NOT>> debugged for CP/M86*/
dirmsk()
{
char *pattp;
sint drv;
pattp = patt; /* use pattern find array to save extnl space */
if (scans(patt,FILELEN) == ESCKEY) return (YES);
drv = curdsk+1; /* drv = num for bdos file search */
if (!*pattp) pattp = "*.*";
else
if (patt[1] == ':') {
if ( ((drv = (toupper(*pattp) - '@')) < 1) || (drv > 16) )
drv = curdsk+1;
pattp += 2;
}
expmsk(drv,pattp);
}
expmsk(drv,str) /* create wildcard cp/m filename from str*/
sint drv;
char *str;
/* input: str: a user input string to expand to legal cp/m wildcard name
output: dirmsk: a string wh/ is a legal cp/m wildcard file name */
{ /* 10 */
sint stop,inmsk,inwild;
char c, wildarray[15], *wildname;
for (inwild=0;inwild<15;wildarray[inwild++]=' ');
wildname = wildarray; /* use pattern change array to save space */
wildname[0] = drv;
wildname[12] = '?';
wildname[14] = '\0';
stop = 8;
inmsk = 0; /* index for input mask */
inwild = 1; /* index for directory mask (output) */
while ((wildname[inwild]) && (str[inmsk])) {
switch (c=str[inmsk++]) { /*30*/
case '*' :
for( ; (inwild <= stop);inwild++)
wildname[inwild] = '?';
stop = 11;
break;
case '.' :
inwild = 9;
stop = 11;
break;
default:
wildname[inwild++] = toupper(c);
break;
} /*30*/
}
printdirectory(wildname);
} /*10*/
printdirectory(wildname)
char *wildname;
{
int y, *dsm, cols, loc, i, ndb, pos;
unsigned blsr, used, recs;
char c, a, entriesonline, *bsh, exm, al0;
char *parms;
sint dmabuf[128],drive;
putclr();
gotoxy(0,6);
putstr("Can't print directory yet.");
_os(SETDMA,dmabuf);
drive = wildname[0]-1;
gotoxy(0,6);
putstr("Directory of ");
putch(drive + 'A');
putch(':');
if (curdsk != (drive) && seldisk(drive) != FAIL) {
putstr(" |(default drive is ");
putch(curdsk+'A');
putstr(":|)");
}
used=0;
parms=_os(DSKPARAMS);
bsh = parms+2;
exm = *(parms+4);
dsm = parms+5;
al0 = *(parms+9);
blsr = (1 << *bsh)/8;
/*block size in kbytes*/
for(ndb=0;al0;al0 <<= 1, ndb++);
entriesonline=0;
begdim();
deleteline(2,(y=8));
pos=_os(SEARCH1,wildname);
while (pos != 0xff) {
loc= pos << 5;
recs = (exm) ? EXTSIZ*(dmabuf[loc+EXTENT]%((exm)+1))
+ dmabuf[loc+RECORDS]
: dmabuf[loc+RECORDS];
used += (recs/(8*blsr))*blsr;
if (recs%(8*blsr)) used += blsr;
if (dmabuf[loc+EXTENT] <= exm) {
for (i=1, cols=0; i < 12; i++) {
c= dmabuf[loc+i] & 0x7f;
if (i == 9 && c != ' ') {
cols++;
putch('.');
}
if (c != ' ') {
cols++;
putch( (i >= 9 ? tolower(c) : c));
}
}
while (cols++ < 12) putch(' ');
if (++entriesonline == 5) {
deleteline(2,++y);
if (y == SHEIGHT) {
putstr("[||<cr>| for MORE...]");
a = getkey();
begdim();
delpage((y=8));
gotoxy(2,8);
/* goto incomplete; */
}
entriesonline=0;
}
else putstr(" : ");
}
pos=_os(SEARCHN,wildname);
}
gotoxy(50,SHEIGHT);
for (i=1;((wildname[i]=='?') && (i<12)); i++);
if (i==12) {
putstr("Free = ");
uspr((((*dsm+1)-ndb)*blsr)-used);
putstr("k ");
}
putstr("Files = ");
uspr(used);
putch('k');
if (curdsk != drive) seldisk(curdsk);
enddim();
gotoxy(0,0);
return;
}
#endif
#if DOS2
dirmsk() /* in MSDOS 2.x just pass the string to showdir
maintain dirmsk call for other functions */
{
char *pattp;
pattp=patt;
if (scans(patt,FILELEN) == ESCKEY) return YES;
if (!*pattp) pattp = "*.*";
showdir(pattp);
}
showdir(msk) /* show msdos directory from ambiguous mask */
char *msk; /* assumes vers.2.x, allows path names */
{
char dtabuf[43], *dirsp, curdir[64], *curdirp;
char *bufp,first, driven, drivel, entriesonline, a, c;
long fsize,*sizep,used,free;
int x,y,i;
/* init display */
putclr();
/* has a drive been specified?*/
for (i=0;( (c=msk[i++]) && (c != ':') ););
if (c) {
drivel = toupper(msk[(i-=2)]);
{
if ( ((driven = drivel-'A') < 0) || (driven > 15)) {
driven=curdsk;
drivel=driven+'A';
}
}
}
else {
driven=curdsk;
drivel=driven+'A';
}
curdirp=curdir;
*curdirp=0;
gotoxy(0,6);
if (getpath(curdirp,(driven+1))==FAIL) return NO;
putstr("Directory of ");
dispch(drivel);
putstr(":\\");
putstr(curdirp);
if (curdsk != (driven) && seldisk(driven) != FAIL) {
putstr(" |(default drive is ");
putch(curdsk+'A');
putstr(":|)");
}
/* get disk free space */
_rax = (FREESP << 8);
_rds = -1;
_rdx = driven+1;
_rcx = 0x00;
_doint(DOSINT);
if(_rax==0xffff) {
error("Bad drive");
return (_rax);
}
/*use "1L" to force unsigned to long conversion*/
free = 1L*(_rax) * (_rbx) * (_rcx);
deleteline((x=2),(y=8));
dirsp="=||dir|";
entriesonline=0;
used=0;
for (i=0;i<43;i++)
dtabuf[i]=0;
_os(SETDMA,dtabuf);
first=TRUE;
do {
_rax = ( (first) ? (0x4e << 8) : (0x4f << 8) ); /* find first&next */
_rdx = msk; /* point to path */
_rds = -1; /* use current ds */
_rcx = 0x30; /* show normal, dir and archived files */
_doint(DOSINT); /* goto DOS */
if (_rax == 2) { /* bad path */
error("Bad path");
return NO;
}
if ( (_rax != 18) ) { /* name is found */
begdim();
first=FALSE;
sizep=&dtabuf[0x1a];
fsize= *sizep;
used+=fsize;
bufp=&dtabuf[0x1e];
putstr(bufp);
if (dtabuf[0x15]==0x10) putstr(dirsp); /*entry is directory*/
/*put code to show if archive bit set, here */
if ((++entriesonline<5))
gotoxy((x+=15),y);
else {
deleteline((x=2),++y);
if (y==SHEIGHT) {
putstr("[||<cr>| for MORE...]");
a=getkey();
begdim();
delpage((y=8));
gotoxy((x=2),y);
}
entriesonline=0;
}
}
}
while ( (_rax != 18) );
gotoxy(40,SHEIGHT);
putstr("Free = ");
uspr(0,free);
putstr(" Files = ");
uspr(0,used);
if (curdsk != driven) seldisk(curdsk);
enddim();
gotoxy(0,0);
return (_rax);
}
#endif
envir()
{
char c;
int maxlines;
struct addr anaddr;
puttext();
do {
putclr();
putstatusline(cline);
gotoxy(0,3);
putstr("Edit context: |(|F| for file context)|\n\n");
putstr("A|uto indent ");
putonoff(autoin);
putstr("B|ackup altered file ");
putonoff(backup);
putstr("D|efault backup path ");
putstr(bakpath);
putstr("\nT|ab stops every ");
uspr(tabwidth,0L);
putstr("\nS|trip trailing blanks ");
putonoff(!trail);
putstr("L|ine and column ");
putonoff(displaypos);
#if WWRAP
putstr("R|ight margin ");
uspr(rtmarg,0L);
#endif
putstr("\nH|orizontal scroll page ");
putonoff(blockscroll);
putstr("E|xpert prompts ");
putonoff(expert);
putstr("O|nscreen help ");
putonoff(helpon);
#if VRSNNUM
putstr("V|ersion update ");
putonoff(version);
#endif
/*
putstr("\n|Memory allows for no more than ");
uspr( ((slotsinmem-2)*(PAGESIZE/(sizeof(anaddr)))) ,0L);
putstr("| lines of text");
*/
putstr("\n|Current line ");
uspr(cline,0L);
putstr(" is |");
maxlines=(slotsinmem-2)*(PAGESIZE/(sizeof(anaddr)));
uspr( (unsigned)(((long)cline*100)/maxlines),0L);
putstr("% |of ");
uspr(maxlines,0L);
putstr(" maximum lines.");
putstr("\n\n\nTo change context, enter letter, or |Q| to return: ");
switch((c=getlow())) {
case 'a':
autoin= !autoin;
break;
case 'b':
backup= !backup;